<?php

function updateDateUser($name,$table_name)
{
   $thedate = date('Y-m-d');
           
   $sql = ("UPDATE $table_name SET last_update='".mysql_real_escape_string($thedate)."' WHERE user_name='".mysql_real_escape_string($name)."' ");
   mysql_query($sql) or die('impossible de modifier le resume'.mysql_error());

}

function getLastAction($user)
{
   include 'connect.php';
   $sql = ("SELECT user_id FROM $table_name WHERE user_name='".$user."'");
   $result = mysql_query($sql,$db);
   $user_id = mysql_fetch_array($result);
   
   $sql = ("SELECT user_id,action_id,action_text FROM wiadn WHERE user_id='".$user_id[0]."' ORDER BY curdate DESC LIMIT 1");
   $result = mysql_query($sql,$db);
   $action = mysql_fetch_array($result);
   return $action;
}

function disDate($date,$int="/",$sep="-"){
               $item = explode($int,$date);
               return $item[1].$sep.$item[0];
}

function checkUsername($login)
{
	$allLogin[0] = "mat";
   $allLogin[1] = "julien";
   $allLogin[2] = "admin";
   $code = 0;
   foreach( $allLogin as $key )
   { 
      if ( $login == $key )
      {
         $code = 1;
      }
      
      return $code;
   
   }
}

function stillLooking($login)
{
   include "connect.php";
   $sql = "SELECT still_looking FROM $table_name 
           WHERE user_name='$login'";
   $result = mysql_query($sql,$db);
   $still_looking = mysql_fetch_array($result);
   return $still_looking[0];
}

?>
